package org.dfl.plugin.editor.commands;

import org.dfl.core.data.types.Type;
import org.dfl.core.data.types.TypeManager;
import org.dfl.plugin.editor.model.ConnectionModelElement;
import org.dfl.plugin.editor.model.NestedConnectionModelElement;
import org.dfl.plugin.editor.model.PlaceModelElement;
import org.dfl.plugin.editor.model.Shape;

/**
 * command that create nested/unnested connection
 * @author Piotr Wlodarczyk
 *
 */
public class NestedConnectionCreateCommand extends ConnectionCreateCommand {
	public NestedConnectionCreateCommand(Shape source) {
		super(source);
	}

	@Override
	protected Type getTargetTransitionType(PlaceModelElement p) {
		return TypeManager.getCollectionType(p.getPlace().getTypeContainer().getType());
	}
	
	@Override
	protected ConnectionModelElement getNewConnectionModelElement(Shape source, Shape target) {
		return new NestedConnectionModelElement(source, target);
	}
}
